package edu.bbu.license.client.android.gui.transfer.adapter;

import java.util.LinkedList;
import java.util.List;

import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import edu.bbu.license.client.android.gui.transfer.model.FileTransferItem;

public class FilesTransferActivityTransferAdapter extends BaseAdapter {

	private LinkedList<FileTransferItem> fileTransferItems = new LinkedList<FileTransferItem>();
		
	public void addItem(FileTransferItem item) {
		fileTransferItems.addFirst(item);
		notifyDataSetInvalidated();
	}
	
	public void removeItem(FileTransferItem item) {
		fileTransferItems.remove(item);
		notifyDataSetInvalidated();
	}
	
	public void addItems(List<FileTransferItem> items) {
		fileTransferItems.addAll(0, items);
		notifyDataSetInvalidated();
	}
	
	public void removeItems() {
		fileTransferItems.clear();
		notifyDataSetInvalidated();
	}

	public LinkedList<FileTransferItem> getFileTransferItems() {
		return fileTransferItems;
	} 
	
	@Override
	public int getCount() {
		return fileTransferItems.size();
	}

	@Override
	public long getItemId(int id) {
		return id;
	}
	
	@Override
	public Object getItem(int location) {
		return fileTransferItems.get(location);
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parrent) {
		return fileTransferItems.get(position).getView();
	}
}
